//
//  WorkOrderDetailViewController.m
//  NewPro
//
//  Created by RYX on 2018/11/23.
//  Copyright © 2018年 何荧红. All rights reserved.
//

#import "WorkOrderDetailViewController.h"
#import "PostWorkOrderViewController.h"
#import "WorkOrderStore.h"
#import "WorkOrderList.h"
#import "WorkOrderModel.h"
#import "WorkOrderDetailModel.h"

@interface WorkOrderDetailViewController ()
{
    __weak IBOutlet UILabel *typeLa;
    __weak IBOutlet UILabel *contentLa;
    
    __weak IBOutlet UILabel *nameLa;
    __weak IBOutlet UILabel *noLa;
    
    __weak IBOutlet UILabel *cardNoLa;
    __weak IBOutlet UILabel *moneyLa;
    
    __weak IBOutlet UILabel *timeLa;
    
    __weak IBOutlet UIScrollView *sView;
    
    
}

@property (nonatomic,strong) ViewHeader *header;

@end

@implementation WorkOrderDetailViewController

- (ViewHeader *)header{
    
    if (!_header) {
        
        _header = [[ViewHeader alloc] initWithDefaultString:@"工单详情"];

    }
    
    return _header;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setNavBarWithTitle:@"工单详情"];
    
    [sView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.left.right.bottom.equalTo(self.view);
        
    }];
    
    [self refresh];
}

- (void)refresh{
    
    WorkOrderStore *store = [[WorkOrderStore alloc] init];
    
    MJWeakSelf
    [store getWorkOrderDetailWithWorkOrderId:[WorkOrderList sharedInstance].selectedModel.uid Success:^(WorkOrderDetailModel *model) {
        
        dispatch_async(dispatch_get_main_queue(), ^{
           
            self->typeLa.text = model.workOrderType;
            self->contentLa.text = model.content;
            
            self->nameLa.text = model.merchantName;
            self->noLa.text = model.merchantNo;
            
            self->cardNoLa.text = model.cardNo;
            self->moneyLa.text = model.tMoney;
            self->timeLa.text = model.transactionTime;
            
        });
        
        
    } Failure:^(NSError *error) {
        
        [weakSelf showMBPError:[HttpTool handleError:error]];
    }];
}

- (IBAction)onNOHandleBtn:(UIButton *)sender {
    
    [self.navigationController popViewControllerAnimated:YES];
}


- (IBAction)onHandleBtn:(UIButton *)sender {
    
    PostWorkOrderViewController *VC = [[PostWorkOrderViewController alloc] init];
    [self.navigationController pushViewController:VC animated:YES];
}

@end
